<template>
    <rui-page :defines="defines">
        <rui-query :label-width="180"
                   ref="searchForm"
                   :query="queryData"
                   :query-rows="searchFormOptions"
        >
        </rui-query>
        <rui-table :defineId="'mqErrorDefine'"
                   :fixedLeft="['contractNo']"
                   :showIndex="false"
                   :select="false"
                   :columns="mqErrorColumn"
                   @loadDatas="queryData"
                   ref-query="searchForm"
                   ref="mqErrorTable"
        >
        </rui-table>
    </rui-page>
</template>
<script>
    import mqErrorDefine from "./mq-error-define";
    import {getMqErrorList} from "_p/basic/api/contract/common/mq-error/mq-error";

    export default {
        data() {
            return {
                searchFormOptions: [
                    {
                        defineId: "mqErrorDefine",
                        fields: ["applyNo", "contractNo", "mqBusinessType"]
                    }
                ],
                mqErrorColumn: ['applyNo', 'contractNo', 'mqBusinessType', 'mqMessage', 'errorMessage']
            };
        },
        computed: {
            defines() {
                return [
                    {
                        id: "mqErrorDefine",
                        fields: mqErrorDefine
                    }
                ];
            }
        },
        activated() {
            this.refresh();
        },
        methods: {
            queryData(queryData) {
                getMqErrorList(queryData).then(res => {
                    if (res.code === "0000") {
                        let {records, total} = res.data;
                        this.$refs.mqErrorTable.updateTableData(records, total);
                    }
                });
            },
            refresh() {
                this.$refs['mqErrorTable'].reloadData();
            }
        }
    };
</script>
